<%--
  Created by IntelliJ IDEA.
  User: H64
  Date: 2021/4/20
  Time: 16:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>年级列表</title>
    <script src="/statics/js/jquery-1.12.4/jquery-1.12.4.min.js" type="text/javascript"></script>
    <script>
        $(function (){
            $("#btn_batch").click(function (){
                var  ck = $("input[type='checkbox']:checked");
                if (ck.length == 0){
                    alert("请至少选择一条数据进行删除");
                    return;//直接返回
                }
                var gids = [];
                //遍历数组
                for (var  i = 0;i<ck.length;i++){
                    gids[i] = ck[i].value;
                }
             if (confirm('确定要删除'+gids.toString()+"吗？")) {
                 //如果长度不是0，请求后台直接删除选中的数据
                 $.ajax({
                     url: '/delGradeByIds',
                     data: {'gids': gids},
                     success: function (result) {
                         if (result == "ok"){
                             alert("删除成功！！！！！！！");
                             window.location.href = "/gradeList";
                         }
                     }
                 });
             }
            });

            //对查询按钮时间的监听
            $("#btn_query").click(function (){
                //获取的年级编号
                var gid = $("#gradeID").val();
                //发送请求到controller后台
                $.ajax({
                    url: '',
                    data: '',
                    success:function (result){
                        for (var k=0;k<result.studentList.length;k++){
                            // html+=
                        }
                    },
                    error:function (error){

                    }
                });
            });
        });
    </script>
</head>
<body>
<h1>共有${glist.size()}条数据记录</h1>
<div>
   年级编号： <input type="text" id="gradeID"/>
    <input type="button" value="查询" id="btn_query"/>
</div>


<div><a href="/addGrade" >添加年级信息</a></div>

<input id="btn_batch" type="button" value="批量删除">

<table border="1" cellpadding="0" cellspacing="0">
    <thead>
    <tr>
        <td>年级</td>
        <td>年级编号</td>
        <td>年级名称</td>
        <td>操作</td>
    </tr>
    </thead>
<tbody>
<c:if test="${glist != null && glist.size()>0}">
    <c:forEach items="${glist}" var="eachRow" >
        <tr>
            <td ><input type="checkbox" value="${eachRow.gid}"></td>
            <td >${eachRow.gid}</td>
            <td >${eachRow.name}</td>
            <td><a href="/updateGradeById?gid=${eachRow.gid}">更新</a>
                &nbsp;&nbsp;&nbsp;
                <a href="/delGradeById?gid=${eachRow.gid}">删除</a>

           </td>

        </tr>
    </c:forEach>
</c:if>

</tbody>
</table>
</body>
</html>